package com.example.aninterface.OneFragment;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;


import com.example.aninterface.Adapter.MeAdapter;
import com.example.aninterface.R;
import com.example.aninterface.javabean.MeBean;

import java.util.ArrayList;
import java.util.List;

public class Fragment extends android.support.v4.app.Fragment {

    ListView meListView;

    ArrayAdapter<MeBean> adapter;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        @SuppressLint("RestrictedApi") View view = getLayoutInflater(savedInstanceState).inflate(R.layout.fragment_1,container,false);
        meListView = (ListView)view.findViewById(R.id.me_listview);
        meListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Toast.makeText(getContext(),"第" + i + "条" ,Toast.LENGTH_SHORT).show();
            }
        });
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        List<MeBean> lists = new ArrayList<>();
        MeBean meBean = new MeBean();
        meBean.setDistanceShow(true);
        meBean.setIsrightImgShow(true);
        meBean.setLeftImgId(R.mipmap.me);
        meBean.setRightImgId(R.mipmap.right_arrow);
        meBean.setTitle("yaoyi");
        meBean.setTitle("微信号：YYXYXYY520");
        lists.add(meBean);

        meBean=new MeBean();
        meBean.setDistanceShow(true);
        meBean.setIsrightImgShow(true);
        meBean.setLeftImgId(R.mipmap.camera);
        meBean.setRightImgId(R.mipmap.right_arrow);
        meBean.setTitle("相机");
        lists.add(meBean);

        meBean=new MeBean();
        meBean.setDistanceShow(false);
        meBean.setIsrightImgShow(true);
        meBean.setLeftImgId(R.mipmap.favorite);
        meBean.setRightImgId(R.mipmap.right_arrow);
        meBean.setTitle("收藏");
        lists.add(meBean);

        meBean=new MeBean();
        meBean.setDistanceShow(false);
        meBean.setIsrightImgShow(true);
        meBean.setLeftImgId(R.mipmap.photo_album);
        meBean.setRightImgId(R.mipmap.right_arrow);
        lists.add(meBean);
        meBean.setTitle("相册");

//        meBean=new MeBean();
//        meBean.setDistanceShow(false);
//        meBean.setIsrightImgShow(false);
//        meBean.setLeftImgId(R.mipmap.agu);
//        meBean.setTitle("表情");
//        lists.add(meBean);

        meBean=new MeBean();
        meBean.setDistanceShow(true);
        meBean.setIsrightImgShow(true);
        meBean.setLeftImgId(R.mipmap.settings);
        meBean.setRightImgId(R.mipmap.right_arrow);
        meBean.setTitle("设置");
        lists.add(meBean);

        adapter = new MeAdapter(getActivity(),R.layout.item_me,lists);
        meListView.setAdapter(adapter);

    }
}

